package com.thirdgroup.dao.impl;

import com.thirdgroup.dao.PhoneBillDao;
import com.thirdgroup.dao.base.BaseDAO;
import com.thirdgroup.pojo.vo.BillInfoVO;

import java.util.List;

public class PhoneBillDaoImpl extends BaseDAO<BillInfoVO> implements PhoneBillDao {
    @Override
    public List<BillInfoVO> selectUserPhone(String userPhone) {
        String sql="select DISTINCT b.billID billID, b.callingPhone callingPhone, \n" +
                "b.calledPhone calledPhone,called.calledOperatorName calledOperatorName,called.calledPrice calledPrice,b.callDuration callDuration,b.phoneCharge phoneCharge,b.createTime createTime\n" +
                "from user_info u , bill_info b,\n" +
                "(select DISTINCT co.calledOperatorPhone userPhone,co.calledOperatorName,cf.calledPrice\n" +
                "from called_operator_info co,call_fees_info cf \n" +
                "where  co.calledOperatorID =cf.calledOperatorName) called\n" +
                "where u.userPhone=b.callingPhone and  called.userPhone=b.calledPhone and u.userPhone=?";
        Object[] params={userPhone};
        return super.findAll(sql,params);
    }
}
